import { BaseModel } from '@/common/base/base.model';
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { EvaluationModel } from "@/module/evaluation/evaluation.model";
import { UserModel } from "@/module/user/user.model";

@Entity('EVALUATION_COMPOSE', {
  synchronize: false,
}) // 评测组，hifi系统
export class EvaluationComposeModel extends BaseModel {
  @Column({
    comment: '标题',
    type: 'varchar',
    length: 500,
  })
  title: string;

  @Column({
    comment: '耳机评测uuid',
    type: 'uuid',
  })
  earbudsEvaluationUuid: string;
  @ManyToOne(() => EvaluationModel, {
    createForeignKeyConstraints: false
  })
  @JoinColumn({
    name: 'earbuds_evaluation_uuid',
    referencedColumnName: 'uuid',
  })
  earbudsEvaluation: EvaluationModel;

  @Column({
    comment: '选用的耳机评测分组',
    type: 'varchar',
    length: 200,
  })
  earbudsEvaluationDataGroup: string;

  @Column({
    comment: '音源评测uuid',
    type: 'uuid',
    nullable: true,
  })
  soundSourceEvaluationUuid: string;
  @ManyToOne(() => EvaluationModel, {
    createForeignKeyConstraints: false
  })
  @JoinColumn({
    name: 'sound_source_evaluation_uuid',
    referencedColumnName: 'uuid',
  })
  soundSourceEvaluation: EvaluationModel;

  @Column({
    comment: '选用的耳机评测分组',
    type: 'varchar',
    length: 200,
  })
  soundSourceEvaluationDataGroup: string;

  @Column({
    comment: '用户uuid',
    type: 'uuid',
  })
  userUuid: string;
  @ManyToOne(() => UserModel, {
    createForeignKeyConstraints: false
  })
  @JoinColumn({
    name: 'user_uuid',
    referencedColumnName: 'uuid',
  })
  user: UserModel;
}
